// 左侧导航组件
<template>
  <div class="sidebar">
    <div class="img-con">
      <img :src="userUrl" alt="">
    </div>
    <p class="username">{{userName}}</p>
    <p class="sign">{{sign}}</p>
    <ul>
      <li v-for="choice in choices" :key='choice' @click='visit'>{{choice}}</li>
    </ul>
  </div>
</template>
<script>
export default {
  name: "sidebar",
  data() {
    return {
      userUrl: "./static/images/data@3x.png",
      userName: "逍 遥",
      sign: "这个人很懒什么都没写",
      choices: ["我的信息", "修改密码", "我的文章", "我的收藏", "我的消息"]
    };
  },
  methods: {
    visit(e) {
      let l = e.target.parentElement.children;
      l = Array.from(l);
      l.forEach(item => {
        item.style.color = "#000";
        e.target.style.color = "red";
      });
      let value = e.target.innerText;
    }
  }
};
</script>

<style scoped>
* {
  font-family: "黑体";
}

.sidebar {
  width: 150px;
  height: 500px;
  padding: 20px 20px 0;
  border-right: 1px solid #d3d3d3;
}

.img-con {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100px;
  height: 100px;
  margin: 0 auto;
  border-radius: 100%;
  background: #d3d3d3;
}

img {
  width: 60px;
}

p {
  margin-top: 0.7rem;
  text-align: center;
  font-weight: bold;
}

p.username {
  font-size: 1rem;
  color: #696969;
}

p.sign {
  font-size: 0.8rem;
}

ul {
  margin: 2rem 1rem;
}

ul li {
  padding-top: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #000;
  list-style: none;
  text-align: center;
  font-weight: bold;
  cursor: pointer;
}
</style>
